import Vue from 'vue';
import Vuex from 'vuex';
import cookies from 'js-cookie';

import menu from './modules/menu'
import user from './modules/user'
import tabs from './modules/tabs'
import routerData from './routerData/routerData'

Vue.use(Vuex);
const store = new Vuex.Store({
  state:{
    token:cookies.get("token")||null,//用户token
  },
  mutations:{
    setToken(state,token){
      state.token = token;
      cookies.set("token",token,{ expires: 1 / 24 });
    },
  },
  actions:{
    setToken({commit},token){
      commit("setToken",token);
    },
  },
  getters:{
    token:state => state.token,//用户token
    userInfo:state => state.user.userInfo,//用户信息

    tabs:state => state.tabs.tabs,//头部tab
    style:state => state.menu.style,//页面风格
    isCollapse:state => state.menu.isCollapse,//是否展开
    isFooter:state => state.menu.isFooter,//是否显示底部栏

    //addRouters:state => state.routerData.addRouters,//动态路由
    //routers:state => state.routerData.routers//菜单列表
  },
  modules:{
    menu,
    //routerData,
    user,
    tabs
  }
})
export default store;
